package com.wcgksoft.controller.admin;

import com.wcgksoft.common.util.Layui;
import com.wcgksoft.common.util.MsgInfo;
import com.wcgksoft.entity.order.Order;
import com.wcgksoft.entity.system.SysUser;
import com.wcgksoft.service.order.OrderService;
import com.wcgksoft.service.system.UserService;
import javafx.scene.chart.ValueAxis;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author 御风
 * @version V1.0
 * @Package com.wcgksoft.controller.admin
 * @Description TODO
 * @date 2020/5/22 22:18
 * @ClassName ViewController
 */
@Controller
@RequestMapping("view")
public class ViewController {

    @Autowired
    private OrderService orderService;

    @Autowired
    private UserService userService;

    @ResponseBody
    @RequestMapping(value = "findOrderInfo")
    public MsgInfo findOrderInfo(@RequestParam(value = "sid",required = false)Integer sid){
        MsgInfo msgInfo = new MsgInfo();
        SysUser sysUser = userService.findById(sid);
        DetachedCriteria criteria = DetachedCriteria.forClass(Order.class);
        criteria.add(Restrictions.eq("sysUser",sysUser));
        List<Order> list = orderService.findByConditions(criteria);
        msgInfo.setData(list);
        return msgInfo;
    }
}
